home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
JCSM Shareware Collection 1996 September
/
JCSM Shareware Collection (JCS Distribution) (September 1996).ISO
/
prgtools
/
11730a01.ziv
/
VTOOLS21.EXE
/
MCGALIB.DOC
< prev
next >
Wrap
Text File
|
1994-05-30
|
9KB
|
272 lines
┌──────────────────────┐
│ THE MCGA-VGA LIBRARY │
└──────────────────────┘
These functions are for the VGA 19, 320 x 200, 256 colors
screen. To see how to use the sprite functions, look at the
EXAMPLE.C listing, and read explanations on EXAMPLE program la-
ter also...
Functions supported are these:
- Set a screen mode.
- Display a text string.
- Clear the screen.
- Put a pixel.
- Get a pixel color.
- Draw line, rectangle.
- Create colors.
- Using several palettes.
- Set a window.
- Get a block of screen.
- Put a block on screen.
- Fill a rectangle.
- Put a 16 color icon on screen.
- Put 256 color sprites:
* In XOR mode.
* In overwriting mode.
* In copy mode.
- Functions for special effects.
- Scrolling hardware or software.
The variables of the library:
VARIABLES FOR GRAPHICAL WINDOW
unsigned int XL=0;
unsigned int XR=319;
unsigned int YB=0;
unsigned int YT=199;
VARIABLE FOR REAL OR VIRTUAL SCREEN
unsigned int VGASCREEN=0xA000;
The default value (0xA000) is the segment adress of the real
screen, one changes segment to use a virtual screen, offset
must be 0.
extern unsigned char TEXTCOLOR; Color for text display.
extern unsigned long *SPVECTOR; Pointer on sprites' addresses.
extern char *SPCODE; Pointer on start of sprites'
code.
The functions of the library:
void selectscreen(int mode);
To change the screen mode: 19 for MCGA screen, 3 for text screen.
char *getspadr(int number);
Returns address of a sprite by sending its number in the ta-
ble, that is in the range 1..N, N being number of sprites in
the table.
void window19(int left, int bottom, int right, int top);
Set a graphical window inside the screen. Left = 0..319,
right = 0..319, bottom = 0..199, top = 0..199.
void DOSwrite(int column, int line, char *text);
Put a string on screen. Column = 1..40, line = 1..25. Color
according to the TEXTCOLOR variable.
void cls19(int color);
Clear the screen with a color among 256.
void sprite256(int x, int y, char *adr);
Put a 256 colors sprite on scenery, without erasing the
background. Address is either an absolute address or the GETS-
PADR function with the sprite number as parameter.
Ex.: sprite256( 5, 18, getspadr( 3 ));
This displays the third sprite in table at x = 5, y = 18.
void csprite256(int x, int y, char *adr);
Put a sprite with its background on the screen. That erases
the scenery. It's very fast and serves to make scenery.
void csprite256c(int x,int y,char *adr);
As csprite256 but inside the user-defined window
void xsprite256(int x, int y, char *adr);
Display a sprite in XOR mode, exclusive or. This change the
colors. By displaying again the sprite one restore the back-
ground.
void sprite(int number, int x, int y, unsigned char mode);
Generical function that calls other sprite functions accor-
ding to the chosen mode:
0 = COPY.
4 = overwriting.
void getblock(int left, int bottom, int right, int top,
char *adr);
Get a block of the screen to the adress This requires an even
width. And one must first allocate a memory buffer at adr
(with the malloc function in C language).
void putblock(int x, int y, char *adr);
Put a block saved with getblock on the screen.
void icon19(int x, int y, char *adr);
Put a 16 color icon on the screen. An icon displays color 0
that is the black color number, and don't display color 9 that
serves to background. It can be made with the k, i or j command
of MegaSprites.
void writeRGB(char *paladr);
Set a 256 color palette from a file of 768 values, pre-
viously loaded in memory at paladr.
void writecolor(int colnum, int r, int g, int b);
Create a new color # colnum with three red, green, and blue
values, that are in range 0..63.
void setpix256(int x, int y, unsigned char color);
Put a pixel at x, y.
int getpix256(int x, int y);
Get the color of pixel at x, y.
void line256(int x, int y, int x2, int y2, unsigned char color);
Draw a line from starting point at x, y to ending point at x2, y2.
void rectangle(int left,int botton,int right,int top);
Draw a rectangle
void fillblock(int l, int b, int r, int h, int color);
Fill a rectangle defined by l, b, r, b (left, bottom, right, top)
with a color among 256.
void synchro();
Wait for a screen refresh.
void appear(char *palette);
Make the screen slowly appearing.
void disappear(char *palette);
Make the screen slowly disappearing.
void MCGAscroll(char decal);
Full screen scolling, does a BIOS call.
void scroll(int dir,int step);
Scrolling of the user-defined window
Step is the number of pixels to move
Dir is the direction:
1 = up
2 = right
3 = down
4 = left
MCGALIB.OBJ
MCGALIB.OBJ holds all the functions detailed above. It's an as-
sembly 80286 set of functions that can be used with any lan-
guage and compiler.
The way to use this assembly module depends of the compiler and
must to be explained in its manual.
This module is assembled for LARGE MODEL, CASE-SENSITIVE, and
symbols are prefixed by the '_' letter, that requires either
you set the appropriate option to your linker, or you prefixe
the functions with '_' at the call.
For example: sprite(x, y, adr)
becomes _sprite(x, y, adr).
The MCGALIB.H file can be included in C files, it is not requi-
red however.
The source code MCGALIB.C or MCGALIB.ASM that is provided if a
registered version can so be included in a C or assembly module
or translated to another language.
┌─────────────────────┐
│ THE EXAMPLE PROGRAM │
└─────────────────────┘
Files used by the program:
DEMO2.SPR File of sprites.
DEMO2.AUT File of an automaton.
EXAMPLE.C C ANSI source file for example of use.
EXAMPLE.EXE The executable.
EXAMPLE.PRJ A TC 2.0 project example.
MCGALIB.OBJ Assembly 80286 library of graphical and
sprite functions.
MCGALIB.H Header file of MCGALIB.OBJ for C compilers.
The EXAMPLE program is a very simple program to show how to use
sprites and automaton. It uses MCGALIB.OBJ and also it includes
all necessary functions for sprite management: loading sprite,
converting addresses after loading, making scenery, etc..
Variables for sprite using:
FILE *FP; Used by file functions.
int *AUTOMATON; Pointer on a buffer for automaton.
char *BLOCKSAVE; Pointer on a buffer for screen block.
int AUTMAX; Number of entries in automaton.
int SPRMAX; Number of sprites in table.
Fonctions for sprite using:
void outtextf(int x,int y,char *fmt, ... );
Display a formatted text string at x, y. As printf for gra-
phical screen.
x=0..40
y=0..24
int autread(int i);
Function to read frame i of loaded automaton, return the
sprite number to this frame.
int getcode(int n);
Function that returns code of format of sprite #n.
Function for loading files:
void changext(char *name,char *ext);
Add or replace extension of filename by the proper one.
Assume size of variable names is large enough to handle a 13
characters long string.
int bload(char *fname,char *adr,int siz);
Load any binary file. Return 1 if OK, 0 otherwise.
int autload(char *aname);
Load automaton "aname" at AUTOMATON location. Assume AUTOMA-
TON points out a memory buffer allocated with function of the
language.
int sprload(char *spname);
Load the file of sprites "spname", at SPVECTOR location. SP-
VECTOR is a pointer defined in MCGALIB, and it must be alloca-
ted before loading sprites into memory. The function is shorte-
ned to load file until 64 Kb long if a unregistered version,
and it is the same as that of VTools if the registered version.
It convert relative addresses to absolute ones.
Return 1 if OK, 0 otherwise.
When returning, SPVECTOR points out the table of adresses of
the sprites, and SPCODE points out the images.
The main loop of the program:
This program is a short example to show how to use 256 co-
lor sprites on a scenery without erasing the scenery.
The scenery is a single sprite that covers background. The main
iteration saves the block of screen where animation is done,
puts the sprite, restores the screen, then one repeats the ope-
ration at the next location, and so on... Even if it's very
simple, this example holds all that is required for a strategy
or role-playing game. To make an arcade game, the color planes
principle is required and that is for the PLIB library and its
example...